using System;
using Asteroid.Content;
using Asteroid.Screens;
using GameFramework;
using GameFramework.Diagnostics;
using Microsoft.Phone.Shell;

namespace Asteroid
{
    /// <summary>
    /// The asteroid game object.
    /// </summary>
    public class AsteroidGame : BaseGame
    {
        public override bool SaveAndLoadStatusAutomatically
        {
            get
            {
                return true;
            }
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();

            Fonts.LoadAllFonts();
            Textures.LoadAllTextures();
            Sounds.LoadAllSounds();
        }

        /// <summary>
        /// Game launching handler.
        /// </summary>
        protected override void GameLaunching()
        {
            SimulateTrialMode();
            ScreenManager.NavigateTo(new MenuScreen());
        }

        /// <summary>
        /// Game closing handler
        /// </summary>
        protected override void GameClosing()
        {
            // Don't save the game status when the user close the game
        }

        protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            using(new CodeTimeCounter("Update: {0}"))
            {                 
                base.Update(gameTime);
            }
        }

        /// <summary>
        /// Game activated handler.
        /// </summary>
        protected override void  GameActivated()
        {
            base.GameActivated();

            if (!GameStatusAvailable)
            {
                ScreenManager.NavigateTo(new MenuScreen());
            }
        }
    }
}
